function nextPt = GetMinDistance(srcPt, route)
routeSize = size(route);
xsize = routeSize(1,1);
nextPt = route(1,:);
distance = 2^16;
src = cast(srcPt, "int32");
for x = 1:xsize
    pt = cast(route(x,:), "int32");
    ptDistance = sqrt(sum((src - pt).^2));
    if (ptDistance < distance)
        distance = ptDistance;
        nextPt = pt;
    end
    if (distance == 1)
        return
    end
end

